package at.dl.android.dota.adviser;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

//        ErrorReporter errorReporter = new ErrorReporter();
//        errorReporter.Init(getApplicationContext());
//        errorReporter.CheckErrorAndSendMail(getApplicationContext());
        
        Button btnSearchHeroes = (Button) findViewById(R.id.searchHeroButton);
        btnSearchHeroes.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                try {
                    Intent myIntent = new Intent(view.getContext(), SearchHeroActivity.class);
                    startActivity(myIntent);
                }
                catch ( Exception ex ) {
                    throw new RuntimeException(ex);
                }
            }
        });
        Button btnSearchItems = (Button) findViewById(R.id.searchItemButton);
        btnSearchItems.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                try {
                    Intent myIntent = new Intent(view.getContext(), SearchItemActivity.class);
                    startActivity(myIntent);
                }
                catch ( Exception ex ) {
                    throw new RuntimeException(ex);
                }
            }
        });
    }
    
    @Override
    protected void onResume () {
        super.onResume();
        DataBaseHelper myDbHelper = new DataBaseHelper(getBaseContext());
        try {
            myDbHelper.createDataBase();
        } catch ( IOException ioe ) {
            throw new RuntimeException("Unable to create database",ioe);
        }
    }
    
}